#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
LL a[100007];
bool cmp(int a, int b) {
    return a>b;
}
int main() {
    int n;
    cin>>n;
    for (int i=0; i<n; ++i) scanf("%lld", a+i);
    sort(a, a+n, cmp);
    LL res = 0;
    for (int i=0; i<n; ++i) {
        if (i%2==0) res += a[i];
        else res -= a[i];
    }
    cout<<res<<endl;
    return 0;
}
